<?php
include_once(SYSTEM.'/ValidationRule.php');

class StringLengthRule extends ValidationRule
{
	public $Min = 0;
	public $Max = 0;

	public function __construct($min, $max, $message)
	{
		$this->Min = $min;
		$this->Max = $max;
		
		if(!isset($message))
		{
			$message = 'Do dai cua sau ki tu khong hop le';
		}
		parent::__construct($message);
	}

	public function Validate($param)
	{		
		if($this->Max != 0 && $this->Min != 0 && $this->Min > $this->Max) 
		{
			echo '$min PHAI NHO HON $max';	
		}
		else if(strlen($param) > $this->Max && $this->Min == 0)
		{
			return $this->Message;
		}
		else if(strlen($param) < $this->Min && $this->Max == 0) 
		{
			return $this->Message;
		}
		else if(strlen($param) < $this->Min && strlen($param) > $this->Max && $this->Min != 0 && $this->Max != 0) 
		{
			return $this->Message;
		}
		return 'OK';
	}
}